package v1

import (
	"gitee.com/liangziyisheng/caas-platform-mc/internal/consts"
	"gitee.com/liangziyisheng/caas-platform-mc/internal/model/do"

	"gitee.com/liangziyisheng/caas-platform-mc/internal/model/entity"

	"github.com/gogf/gf/v2/frame/g"
)

// req and resp struct
type TypesReq struct {
	g.Meta `path:"/orgs/types" tags:"组织管理" method:"get" summary:"组织类型列表"`
}

type TypesRes struct {
	Data []consts.DdicType1 `json:"data" description:"组织类型列表"`
}

type ListReq struct {
	g.Meta `path:"/orgs" tags:"组织管理" method:"get" summary:"组织列表"`
}
type ListRes struct {
	g.Meta `mime:"application/json"`
	Data   []*Org `json:"data" description:"组织列表"`
}
type AddReq struct {
	g.Meta `path:"/orgs" tags:"组织管理" method:"post" summary:"添加组织"`
	Code   string `json:"code" v:"regex:^[0-9]{6,10}$" description:"组织编码"`
	Name   string `json:"name"    v:"required"   description:"组织名称"`
	Type   int    `json:"type"   v:"in:1,2,3" description:"类型: 1公司2分公司3部门"`
	Parent int64  `json:"parent" v:"required" description:"上级组织ID"`
}
type AddRes struct {
	g.Meta `mime:"application/json"`
	Id     int64 `json:"id" description:"新增组织id"`
}
type UpdateReq struct {
	g.Meta `path:"/orgs/{id}" tags:"组织管理" method:"put" summary:"更新组织"`
	Id     int64  `query:"id" v:"required|min:1" description:"组织ID"`
	Name   string `json:"name"        description:"组织名称"`
}
type UpdateRes struct {
	g.Meta `mime:"application/json"`
	Rows   int64 `json:"rows" description:"修改成功的行数"`
}
type DeleteReq struct {
	g.Meta `path:"/orgs/{id}" tags:"组织管理" method:"delete" summary:"删除组织"`
	Id     int64 `query:"id" v:"required|min:1"`
}
type DeleteRes struct {
	g.Meta `mime:"application/json"`
	Rows   int64 `json:"rows" description:"删除成功的行数"`
}

type Org struct {
	Id       int64  `json:"id"         description:""`
	Code     string `json:"code" description:"组织编码"`
	Name     string `json:"name"       description:"组织名称"`
	Type     int    `json:"type"   description:"类型: 1公司2分公司3部门"`
	Parent   int64  `json:"parent"`
	Children []*Org `json:"children"`
}

// input and output struct
type ListInput struct {
	TenantCode string `json:"tenantCode"`
}
type ListOutput struct {
	Data []entity.Organization `json:"data" description:"组织列表"`
}
type AddInput struct {
	do.Organization
}
type AddOutput struct {
	Id int64 `json:"id" description:"修改成功的行数"`
}
type UpdateInput struct {
	do.Organization
}
type UpdateOutput struct {
	Rows int64 `json:"rows" description:"修改成功的行数"`
}
type DeleteInput struct {
	Id         int64  `json:"id" description:"组织ID"`
	TenantCode string `json:"tenantCode"`
}
type DeleteOutput struct {
	Rows int64 `json:"rows" description:"删除成功的行数"`
}
